﻿using DongFangGuoKai.WMSPlatform.Commn.ExtendModule;
using Microsoft.AspNetCore.Mvc.Filters;

namespace DongFangGuoKai.WMSPlatform.WebApi.Utility.Filters
{
    public class CtmLogActionAsyncFilterAttribute : Attribute, IAsyncActionFilter
    {
        private readonly ILogger<CtmLogActionAsyncFilterAttribute> ctmLogActionlogger;

        public CtmLogActionAsyncFilterAttribute(ILogger<CtmLogActionAsyncFilterAttribute> ctmLogActionlogger)
        {
            this.ctmLogActionlogger = ctmLogActionlogger;
        }

        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {


            ctmLogActionlogger.LogDebug(context.ActionArguments.ToJson());
            await next.Invoke();

            {

                Console.WriteLine(context.Result);
            }

        }
    }
}
